package com.koi.generator.utils;

/**
 * @author ･ᴗ･
 * @description [StrUtil字符串处理工具类]
 */
public class StringHumpUtil {

    /**
     * @description [去掉下划线转小驼峰user_name -> userName]
     * @author ･ᴗ･
     */
    public static String getSmallHump(String str) {
        String name = str;
        if (name.indexOf("_") > 0 && name.length() != name.indexOf("_") + 1) {
            int lengthPlace = name.indexOf("_");
            name = name.replaceFirst("_", "");
            String s = name.substring(lengthPlace, lengthPlace + 1);
            s = s.toUpperCase();
            str = name.substring(0, lengthPlace) + s + name.substring(lengthPlace + 1);
        } else {
            return str;
        }
        return getSmallHump(str);
    }

    /**
     * @description [去掉下划线转大驼峰sys_login_user -> SysLoginUser]
     * @author ･ᴗ･
     */
    public static String getBigHump(String str) {
        String s = getSmallHump(str);
        return s.substring(0, 1).toUpperCase() + s.substring(1);
    }

    public static void main(String[] args) {
        System.out.println(StringHumpUtil.getSmallHump("sys_name"));
        System.out.println(StringHumpUtil.getBigHump("sys_login_user"));
    }
}
